package com.njwb.day15.zqzb.game;

import java.util.Random;

public class AbcGenImpl implements IGenStrategy {

    String MESSAGE = "qwertyuiopasdfghjklzxcvbnm";

    @Override
    public String genString(Player player) {
        Random random  = new Random( );
        StringBuffer stringBuffer = new StringBuffer();
        int length = 0 ;
        //得到玩家的级别号
        int levelNo =player.getLevelNo()-1;
        length = LevelParams.LEVELS[levelNo].getStrLength();
        for(int i = 0 ;i<length;i++) {
            //index [0,MESSAGE.length-1]
            int index =random.nextInt(MESSAGE.length());
            stringBuffer.append(MESSAGE.charAt(index));
        }
        return stringBuffer.toString() ;
    }
}
